<include file="Public:header" />
<div class="subnav">
  <div class="explain-col" style="position: relative;">
    <form name="searchForm" id="searchForm" method="GET" action="" onsubmit="return checkForm()">
      搜索：<input type="text" name="keyword" id="keyword" size="30"  value="{$Think.get.keyword|getChineseGetValue}" class="input-text" onclick="if(this.value=='请输入联系人姓名或电话号码')this.value=''"  onblur="if(this.value=='')this.value='请输入联系人姓名或电话号码'" style="height:20px; width:180px; color:#999" />

      <select name="searchType" id="searchType"  >
            <option value="0" selected="selected">全部</option>
            <option value="6" <eq name="Think.get.searchType" value="6"> selected="selected"</eq> />本月</option>
            <option value="1" <eq name="Think.get.searchType" value="1"> selected="selected"</eq> />上月</option>
            <option value="2" <eq name="Think.get.searchType" value="2"> selected="selected"</eq> />本周</option>
            <option value="3" <eq name="Think.get.searchType" value="3"> selected="selected"</eq> />昨天</option>
            <option value="4" <eq name="Think.get.searchType" value="4"> selected="selected"</eq> />今天</option>
            <option value="5" <eq name="Think.get.searchType" value="5"> selected="selected"</eq> />自定</option>
      </select>

      <span id="searchTime" style="display:none;">
      从：<input type="text" class="input-text Wdate" size="20" name="startTime" id="startTime" value="<?php echo date('Y-m-d'); ?>" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly="readonly" />
      到&nbsp;<input type="text" class="input-text Wdate" size="20" name="endTime" id="endTime" value="" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly="readonly" />
      </span>

      <input type="button" value=" 搜索 " class="button" id="searchButton" />
    </form>
      <div class="content-menu" style="position: absolute; right: 30px;top: 5px;">
        <!--<a href="javascript:openWinBox('__URL__/add','添加电话记录',850);" class="add fb"><em>添加电话记录</em></a>-->
      </div>
  </div>
</div>
<!--subnav-->


<div class="pad-lr-10">
  <form name="myform" id="myform" action="" method="GET">
    <div class="table-list">
    <table width="100%" cellspacing="0" style="min-width:900px;">
      <thead>
        <tr>
          <th width="30" align="center">选择</th>
          <th align="center" width="120">通话日期</th>

          <th align="left" width="80">联系人</th>
          <th align="left" width="80">联系电话</th>
          <th align="center">通话内容</th>
          <th align="center" width="120">创建时间</th>
        </tr>
      </thead>
      <tbody  id="list">
        <volist name="list" id="vo">
          <tr id="list-{$vo.id}">
            <td align="center"><input type="checkbox" class="idArr" name="idArr[]" value="{$vo.id}"></td>
            <td align="center">{$vo.talktime|date='Y年m月d日',###}</td>

            <td align="left">{$vo.name}</td>
            <td align="left">{$vo.phone}</td>
            <td align="left">{$vo.content}</td>
            <td align="center">{$vo.create_time|date='Y-m-d H:i:s',###}</td>
          </tr>
        </volist>
      </tbody>
    </table>
    <div class="btn" style="min-width:830px;">
      <div id="pages" style="width:600px;">{$page}</div>
    	<input name="submit" id="checkall" type="button" class="button" value="全选/反选">
        <input name="submit" type="button" class="button" value="删除所选"  onclick="return deleteConfirm();">
        <!-- <input name="submit" type="button" class="button" value="导出电话记录"  onclick="return exportContent();"> -->
    </div>
  </form>
</div>
</body>
</html>
<script type="text/javascript" src="__PUBLIC__/Js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
$(function(){
	var keyword = $('input[name=keyword]').val();
	if( keyword=='' ){
		$('input[name=keyword]').val('请输入联系人姓名或电话号码');
	}

	var searchType = "{$Think.get.searchType}";
	if(searchType==5){
		$("#searchTime").show();
	}else{
		$("#searchTime").hide();
	}
	$("#searchType").change(function(){
		var searchType = $(this).val();
		if(searchType==5){
			$("#searchTime").show();
			return false;
		}
		searchForm();
	})

	//根据参数设置默认选择选项
	var startTime = "{$Think.get.startTime}";
	var endTime = "{$Think.get.endTime}";
	if(startTime!=''){
		$("#startTime").val(startTime);
	}
	if(endTime!=''){
		$("#endTime").val(endTime);
	}

	var dial_status = "{$Think.get.dial_status}";
	if(dial_status!=''){
		$("#dial_status").val(dial_status);
	}

	$('#myform').ajaxForm({
		beforeSubmit:  checkForm,
		success:       complete,
		dataType: 'json'
	});
	function checkForm(){
		var len = $("input[name='spaceid[]']:checked").length;
		if(len < 1){
			msg('请先选择删除项！','warning',3);
			return false;
		}
	}
	var origin = $.artDialog.open.origin;
	function complete(data){
		msg(data.info,data.data);
		if(data.status) setTimeout(function(){origin.location.reload();},1500);
	}

	//全反选
	$("#checkall").click(function(){
		$("input[name=idArr[]]").each(function(){
			if(this.checked == false)
				this.checked = true;
			else
				  this.checked = false;
		});
	});

	$('#groupId').change(function(){
		searchForm();
	})

	$('#userId').change(function(){
		searchForm();
	})

	$('input[name=keyword]').change(function(){
		searchForm();
	})

	$('#dial_status').change(function(){
		searchForm();
	})

	$("#searchButton").click(function(){
		searchForm();
	})

})


function checkedId(){
	var id = new Array();
	var i = 0;
	$("input[name='idArr[]']").each(function() { //由于复选框一般选中的是多个,所以可以循环输出
		if(this.checked == true){
			id[i] = $(this).val();
			i++;
			$('#list-'+$(this).val()).remove();
		}
	});
	return id;
}

function deleteConfirm(){
	window.top.art.dialog({
		content: '确定删除所选数据？',
		ok: function () {
			del();
			return true;
		},
		cancelVal: '取消',
		cancel: true
	});
}

function del(){
	var idArr = Array();
	var i = 0;
	var id;
	$("input[name='idArr[]']").each(function(){
		if(this.checked == true){
			idArr[i] = $(this).val();
			i++;
		}
	});

	if(idArr==''){
		window.top.art.dialog({id:'TNCICC',content: '请选择要删除的数据！',time: 2,icon:'warning'});
		return false;
	}
	
	jQuery.post('__URL__/del_content',encodeURI('id='+idArr),success,'json');
	function success(data){
		if(data.status==1){
			window.top.art.dialog({id:'TNCICC',content: data.info,time: 2,icon:'succeed'});
			setTimeout(function(){window.location.reload();closeWin(1500);},2000);
		}else{
			window.top.art.dialog({id:'TNCICC',content: data.info,time: 2,icon:'warning'});
		}

	}
}

function checkForm(){
	var keyword = $("input[name='keyword']").val();
	keyword = encodeURI(keyword).replace(/%/g,'.s.');
	$("input[name='keyword']").val(keyword);
	return true;
}

function searchForm(){
	$("#searchForm").attr('action','__URL__/contentList');
	$("#searchForm").submit();
}

function exportContent(){

	$("#searchForm").attr('action','__URL__/exportContent');
	$("#searchForm").submit();
	return false;
}
</script>